﻿using UnityEngine;
using UnityEditor;

using System;
using Hont;

public class GameDateTime_Test1 : MonoBehaviour
{
    [ContextMenu("AddMonthTest1")]
    public void AddMonthTest1()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(4);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(24);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest2")]
    public void AddMonthTest2()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(3);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(11);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest3_N1")]
    public void AddMonthTest3_N1()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(-1);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(-1);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest4_M&D")]
    public void AddMonthTest4_M_A_D()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(8);
        dateTime = dateTime.AddDays(2);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(8);
        dateTime2 = dateTime2.AddDays(2);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest5_M2")]
    public void AddMonthTest5_M2()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(7);
        dateTime = dateTime.AddMonths(1);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(7);
        dateTime2 = dateTime2.AddMonths(1);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest6_M8")]
    public void AddMonthTest6_M8()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);
        dateTime = dateTime.AddMonths(1);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2.AddMonths(1);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest7_DM")]
    public void AddMonthTest7_DM()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddDays(2);
        //dateTime = dateTime.AddMonths(7);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddDays(2);
        dateTime2 = dateTime2.AddMonths(7);
        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest8")]
    public void AddMonthTest8()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(4);
        dateTime = dateTime.AddMonths(dateTime.Month);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(12);
        dateTime2 = dateTime2.AddMonths(dateTime2.Month);

        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest9_M_TS")]
    public void AddMonthTest9_M_TS()
    {
        var dateTime = new GameDateTime();
        dateTime = dateTime.AddMonths(1);
        dateTime = new GameDateTime(dateTime.Ticks - 15 * GameDateStandard.Instance.TicksPerDay);

        PrintGameDate(dateTime);

        var dateTime2 = new DateTime();
        dateTime2 = dateTime2.AddMonths(1);
        dateTime2 = dateTime2 - new TimeSpan(15, 0, 0, 0, 0);
        PrintDate(dateTime2);
    }

    [ContextMenu("AddMonthTest10")]
    public void AddMonthTest10()
    {
        var dateTimeA = new GameDateTime(1, 3, 1);
        var dateTimeB = new GameDateTime(1, 1, 1);

        PrintGameDate(dateTimeA);
        PrintGameDate(dateTimeB);

        var ticks = (dateTimeA - dateTimeB).Ticks;
        PrintGameDate(new GameDateTime(ticks));

        Debug.Log("--------------------");

        var dateTime2A = new DateTime(1, 3, 1);
        var dateTime2B = new DateTime(1, 1, 1);

        PrintDate(dateTime2A);
        PrintDate(dateTime2B);

        ticks = (dateTime2A - dateTime2B).Ticks;
        PrintDate(new DateTime(ticks));
    }

    void PrintGameDate(GameDateTime dateTime)
    {
        Debug.Log("Game --- "
            + " Year: "
            + dateTime.Year
            + " Month: "
            + dateTime.Month
            + " Day: "
            + dateTime.Day
            + " Hour: "
            + dateTime.Hour
            + " Minute: "
            + dateTime.Minute
            + " Second: "
            + dateTime.Second);
    }

    void PrintDate(DateTime dateTime)
    {
        Debug.Log("Game --- "
            + " Year: " + dateTime.Year
            + " Month: "
            + dateTime.Month
            + " Day: "
            + dateTime.Day
            + " Hour: "
            + dateTime.Hour
            + " Minute: "
            + dateTime.Minute
            + " Second: "
            + dateTime.Second);
    }
}
